library(tidyverse)
library(arabicStemR)
library(lubridate)
library(ggplot2)
library(stm)

load("thawrah.RData")
docs = thawrah$documents
vocab = thawrah$vocab
meta = thawrah$meta

# topic model -------------------------------------------------------------
t = Sys.time()
topic_model = stm(documents = docs, vocab = vocab, K = 40, init.type = "Spectral", prevalence = ~ rvln, data = meta, seed = 2018)
Sys.time() - t

save(topic_model, meta, file = "k40.RData")

topic_model %>% summary
